package fun.yaozun.study.controller.base;

import fun.yaozun.study.common.MessageKeyEnum;
import fun.yaozun.study.model.RestModel;

/**
 * @Auther: yaozun
 * @Date: 2018/5/9 0009 11:48
 * @Description:
 */
public class BaseController {

    //成功输出
    protected RestModel success(Object obj) {
        return success(MessageKeyEnum.SUCCESS,obj);
    }

    protected RestModel success(MessageKeyEnum messageKeyEnum, Object obj) {
        return new RestModel(messageKeyEnum.getCode(),messageKeyEnum.getMessage(), obj);
    }

    protected RestModel success(String code,String msg, Object obj) {
        return new RestModel(code,msg, obj);
    }
    //异常输出
    protected RestModel excpRestModel() {
        return new RestModel(MessageKeyEnum.ERROR);
    }

    protected RestModel excpRestModel(MessageKeyEnum messageKeyEnum) {
        return  excpRestModel(messageKeyEnum.getCode(),messageKeyEnum.getMessage());
    }

    protected RestModel excpRestModel(String code,String msg) {
        return excpRestModel(code,msg, null);
    }

    protected RestModel excpRestModel(String code,String msg,Object obj) {
        return new RestModel(code,msg, obj);
    }
}
